﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using AncientLand.Service.Entity;
using AncientLand.Service.IDa;

namespace AncientLand.Da
{
    public class CategoryRepository : RepositoryBase<Category>, ICategoryRepository
    {
        public CategoryRepository(IDatabaseFactory databaseFactory)
            : base(databaseFactory)
         {

         }

        public IEnumerable<Category> GetCategoryByPages(int pageIndex, int pageSize, string orderFiled, out int totalRecord)
        {
            var startRecord = pageSize * (pageIndex- 1);
            totalRecord = DataContext.Categorys.Count();
            return this.DataContext.Categorys.OrderByDescending(n=>n.Id).Skip(startRecord).Take(pageSize);
        }
    }
}
